from sklearn.feature_selection import SelectKBest, chi2
import numpy as np

# 创建数据
X = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]])
y = np.array([0, 0, 1, 1])

# 特征选择
selector = SelectKBest(chi2, k=2)
X_selected = selector.fit_transform(X, y)

print("Selected features:\n", X_selected)